<?php
if (isset($_POST ['submitted'])) {

    require_once ('../mysql_connection/for_m_login.php');
    $errors = array();

    if (empty($_POST ['name'])) {
        $errors [] = 'You forgot to enter your name.';
    } else {
        $n = $_POST ['name'];
    }

    if (empty($_POST ['password'])) {
        $errors [] = 'You forgot to enter your password.';
    } else {
        $p = $_POST ['password'];
    }

    if (empty($errors)) {
        testlogin($n, $p);
    } else {
        $errors [] = 'The email address and password entered do not match those on file.';
        $errors [] = mysql_error () . '<br /><br />Query: ';
    }
} else {
    $errors = NULL;
}
?>

<?php 
include ('../include_htmls/manage_head.html');
?>

<?php
if (!empty($errors)) {
    echo '<h1 align="center" id="mainhead">Error!</h1>
	<p align="center" class="error">The following error(s) occurred:<br />';
    foreach ($errors as $msg) {
        echo " - $msg<br />\n";
    }
    echo '</p><p align="center" >Please try again.</p>';
}
?>
<h2 align="center">Login</h2>
<form action="login.php" method="post">
    <p align="center">User Name: <input type="text" name="name" size="20" maxlength="40" />
    </p>
    <p align="center">Password: <input type="password" name="password" size="20"
                                       maxlength="20" /></p>
    <p align="center">
        <input type="submit" name="submit" value="Login"/>
    </p>
    <input type="hidden" name="submitted" value="TRUE" /></form>
<?php
include ('../include_htmls/manage_foot.html');
?>